package cre.tomcat.ch14.startup;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

/**
 * 安全性
 * tomcat bootstrap
 *
 * @Author penglai
 * @Date 2017/1/4.
 */
public class Stopper {

    public static void main(String[] args) {
        try {
            Socket socket = new Socket("127.0.0.1", 8005);
            OutputStream outputStream = socket.getOutputStream();

            String shutdown = "SHUTDOWN";
            for (int i = 0; i <shutdown.length(); i++) {
                outputStream.write(shutdown.charAt(i));
            }

            outputStream.flush();
            outputStream.close();
            socket.close();
            System.out.println("shutdown tomcat on 8005");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
